local Lua__rwkk = fk.CreateSkill {

  name = "Lua__rwkk",

}

local U = require "packages.utility.utility"

Fk:loadTranslationTable {

  ["Lua__rwkk"] = "让我康康",
  ["$Lua__rwkk1"] = "你脸红啦",
  ["$Lua__rwkk2"] = "听话",
  ["#Lua__rwkk-obtain"] = "选择其中一张牌，获得其区域内所有此牌名的牌。",
  [":Lua__rwkk"] = "当你对一名角色造成伤害后，你可以观看并获得其区域内一种牌名的所有牌。",

}

Lua__rwkk:addEffect(fk.Damage, {
  anim_type = "control",
  can_trigger = function(self, event, target, player, data)
    local victim = data.to
    if victim:isAllNude() then return false end
    return target == player and player:hasSkill(Lua__rwkk.name)
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    return player.room:askToSkillInvoke(player, { skill_name = Lua__rwkk.name })
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local victim = data.to
    local cids = victim:getCardIds("hej")
    local card_names = {}
    local get, _ = room:askToChooseCardsAndChoice(player, {
      cards = cids,
      choice = { "OK" },
      skill_name = Lua__rwkk.name,
      obtain_text = "#Lua__rwkk-obtain",
      min_num = 1,
      max_num = 1,
    })
    if #get > 0 then
      for _, id in ipairs(victim:getCardIds("hej")) do
        if Fk:getCardById(id).trueName == Fk:getCardById(get[1]).trueName then
          table.insert(card_names, id)
        end
      end
      if #card_names > 0 then
        local dummy = Fk:cloneCard("dilu")
        dummy:addSubcards(card_names)
        room:obtainCard(player, dummy, false, fk.ReasonPrey)
      end
    end
  end,
})

return Lua__rwkk
